<!DOCTYPE html>
<html>
<head>
    <title>Mortal BBS</title>
    <meta charset="utf-8">
    <meta name="description" content="{$page_info.description}">
    <meta name="keywords" content="{$page_info.keywords}">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    {include file="common/header" /}
</head>
<!-- 结 构 代 码 -->
<body class="layui-layout-body pear-admin">
<!-- 布 局 框 架 -->
<div class="layui-layout layui-layout-admin">
    <button type="button" id="upload_img" class="layui-hide">图片上传</button>
    <!-- 顶 部 样 式 -->
    <div class="layui-header">
        <!-- 菜 单 顶 部 -->
        <div class="layui-logo">
            <!-- 图 标 -->
            <img class="logo">
            <!-- 标 题 -->
            <span class="title"></span>
        </div>
        <!-- 顶 部 左 侧 功 能 -->
        <ul class="layui-nav layui-layout-left">
            <li class="collapse layui-nav-item"><a href="javascript:void(0);" class="layui-icon layui-icon-shrink-right"></a></li>
            <li class="refresh layui-nav-item"><a href="javascript:void(0);" class="layui-icon layui-icon-refresh-1" loading = 600></a></li>
        </ul>
        <!-- 多 系 统 菜 单 -->
        <div id="control" class="layui-layout-control"></div>
        <!-- 顶 部 右 侧 菜 单 -->
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item layui-hide-xs"><a href="javascript:void(0);" class="menuSearch layui-icon layui-icon-search"></a></li>
            <li class="layui-nav-item layui-hide-xs message"></li>
            <li class="layui-nav-item layui-hide-xs"><a href="javascript:void(0);" class="fullScreen layui-icon layui-icon-screen-full"></a></li>
            <li class="layui-nav-item user">
                <!-- 头 像 -->
                <a class="layui-icon layui-icon-username" href="javascript:;"></a>
                <!-- 功 能 菜 单 -->
                <dl class="layui-nav-child">
                    <dd><a user-menu-url="{:url('admin/GoogleAuth/index')}" user-menu-id="goog_auth" user-menu-title="绑定谷歌验证码">绑定谷歌验证码</a></dd>
                    <dd><a href="javascript:void(0);" class="logout">注销登录</a></dd>
                </dl>
            </li>
            <!-- 主 题 配 置 -->
            <li class="layui-nav-item setting"><a href="javascript:void(0);" class="layui-icon layui-icon-more-vertical"></a></li>
        </ul>
    </div>
    <!-- 侧 边 区 域 -->
    <div class="layui-side layui-bg-black">
        <!-- 菜 单 顶 部 -->
        <div class="layui-logo">
            <!-- 图 标 -->
            <img class="logo">
            <!-- 标 题 -->
            <span class="title"></span>
        </div>
        <!-- 菜 单 内 容 -->
        <div class="layui-side-scroll">
            <div id="side"></div>
        </div>
    </div>

    <!-- 视 图 页 面 -->
    <div class="layui-body">

        <!-- 内 容 页 面 -->
        <div id="content"></div>
    </div>
    <!-- 页脚 -->
    <div class="layui-footer layui-text"></div>
    <!-- 遮 盖 层 -->
    <div class="pear-cover"></div>
    <!-- 加 载 动 画 -->
    <div class="loader-wrapper">
        <!-- 动 画 对 象 -->
        <div class="loader"></div>
    </div>
</div>
<!-- 移 动 端 便 捷 操 作 -->
<div class="pear-collapsed-pe collapse">
    <a href="javascript:void(0);" class="layui-icon layui-icon-shrink-right"></a>
</div>

<!-- 依 赖 脚 本 -->
<script src="__ADMINS__component/layui/layui.js"></script>
<script src="__ADMINS__component/pear/pear.js"></script>
<!-- 框 架 初 始 化 -->
<script>
    const mor_up_info = (function () {
        let id;
        let type;
        // 设置全局变量的函数
        function set_up_id(value) {
            id = value;
        }
        function set_up_type(value) {
            type = value;
        }
        // 获取全局变量的函数
        function get_up_id() {
            return id;
        }
        function get_up_type() {
            return type;
        }
        // 暴露公共接口
        return {
            set_up_id,
            set_up_type,
            get_up_id,
            get_up_type
        };
    })();
    function mor_file_upload(id,type) {
        mor_up_info.set_up_id(id);
        mor_up_info.set_up_type(type);
        var upload_btn = document.getElementById("upload_img");
        upload_btn.click();
    }
    layui.use(['admin','jquery','popup','form','toast'], function() {
        var admin = layui.admin;
        var popup = layui.popup;
        var form = layui.form;
        var $ = layui.jquery;
        var upload = layui.upload;
        var toast = layui.toast;

        // 渲染
        admin.render({
            "logo": {
                "title": "Mortal Admin",
                "image": "__ADMINS__admin/images/logo.png"
            },
            "menu": {
                "data": "{:url('admin/Index/get_menu')}",
                "method":"GET",
                "accordion": true,
                "collapse": false,
                "control": true,
                "select": "2",
                "async": true
            },
            "tab": {
                "enable": true,
                "keepState": false,
                "session": false,
                "preload":false,
                "max": 30,
                "index": {
                    "id": "2",
                    "href": "{:url('admin/Index/welcome')}",
                    "title": "数据概览"
                }
            },
            "theme": {
                "defaultColor": "6",
                "defaultMenu": "dark-theme",
                "defaultHeader": "light-theme",
                "allowCustom": true,
                "banner":false,
                "dark": false
            },
            "colors": [{
                "id": "1",
                "color": "#16baaa",
                "second":"#ecf5ff"
            },
                {
                    "id": "2",
                    "color": "#009688",
                    "second":"#ecf5ff"
                },
                {
                    "id": "3",
                    "color": "#36b368",
                    "second":"#f0f9eb"
                }, {
                    "id": "4",
                    "color": "#f6ad55",
                    "second":"#fdf6ec"
                }, {
                    "id": "5",
                    "color": "#f56c6c",
                    "second":"#fef0f0"
                }, {
                    "id": "6",
                    "color": "#3963bc",
                    "second":"#ecf5ff"
                }
            ],
            "other": {
                "keepLoad": 1200,
                "autoHead": false,
                "footer": false
            },
            "header":{
                message: false
            }
        });
        var up_inst = upload.render({
            elem: '#upload_img',
            accept:'file',
            data: {
                type: function(){
                    return mor_up_info.get_up_type();
                }
            },
            url: '{:url($operate.upload)}',
            done: function(res){
                if(res.code === 200){
                    toast.success({
                        message: res.msg,
                    });
                    $("#up_"+mor_up_info.get_up_id()).val(res.data.pic_url);
                    $('#img_p_'+mor_up_info.get_up_id()).removeClass('layui-hide').find('img').attr('src', res.data.pic_url);
                }else{
                    toast.error({
                        message: res.msg,
                    });
                }
            }
        });
        form.render();
        // 注销
        admin.logout(function(){
            $.post('{:url("admin/index/login_out")}',{},function(res){
                if(res.code === 200){
                    popup.success(res.msg, function () {
                        location.href = '{:url("admin/login/index")}';
                    });
                    // 清空 tabs 缓存
                    return new Promise((resolve) => {
                        resolve(true)
                    });
                }else{
                    toast.error({
                        message: res.msg,
                    });
                }
            })
        });
    })
</script>
</body>
</html>